<template>
  <div>
    <f-table ref='table' size='small' rowKey='processId' :columns='columns' :scroll='{x:true}' :multiple='false'
             :operator='operator' :params='queryParam' :api='api.tasktodo.listDone'
             handler='consumptionTaskTodoListHandler'>
        <span slot='paymentType' slot-scope='text, record, index'>
            <a-tag color='#2db7f5' v-if='record.paymentType==1'>采购预付款</a-tag>
            <a-tag color='#f50' v-if='record.paymentType==2'>快递费</a-tag>
            <a-tag color='#108ee9' v-if='record.paymentType==3'>销售费用</a-tag>
            <a-tag color='#87d068' v-if='record.paymentType==4'>市场保证金</a-tag>
            <a-tag color='#d01784' v-if='record.paymentType==5'>其他</a-tag>
            <a-tag color='#d08014' v-if='record.paymentType==6'>开票税金</a-tag>
          <a-tag color='#87d068' v-if="record.paymentType=='PT_01'">采购预付款</a-tag>
          <a-tag color='#87d068' v-if="record.paymentType=='PT_02'">快递费</a-tag>
          <a-tag color='#87d068' v-if="record.paymentType=='PT_03'">销售费用</a-tag>
          <a-tag color='#87d068' v-if="record.paymentType=='PT_04'">其他</a-tag>
          <a-tag color='#87d068' v-if="record.paymentType=='PT_05'">市场保证金</a-tag>
          <a-tag color='#87d068' v-if="record.paymentType=='PT_06'">开票税金</a-tag>
        </span>
      <span slot='action' slot-scope='text, record'>
          <template>
             <a href='javascript:;' @click="$refs['consumptionDrawer'].showDrawer(record,'form2')">查看</a>
             <a-divider type='vertical' />
             <a href='javascript:;' @click='processImg(record)'>审批进度</a>
          </template>
        </span>
    </f-table>
    <consumption-drawer ref="consumptionDrawer"></consumption-drawer>
    <process-image ref='processImg' v-if='processImageVisible' :visible.sync='processImageVisible' :processInstanceId='processInstanceId'></process-image>
  </div>
</template>
<script>

import api from "./../js/api"
import ProcessImage from "../../process/process_image"
import ConsumptionDrawer from '@/views/module/business/consumption/consumption_drawer'
export default {
  name: "TableList",
  components: {
    ProcessImage,
    ConsumptionDrawer
  },
  data() {
    let me = this
    //操作按钮
    let operator = []

    return {
      api: Object.assign(api, this.api),
      //列表初始化查询参数
      queryParam: {},
      processInstanceId: "",
      processImageVisible: false,
      // 表头
      columns: [
        {
          title: "#",
          width: "60",
          align: "center",
          customRender: (text, record, index) => index + 1
        },
        {
          title: "操作",
          align: "center",
          scopedSlots: { customRender: "action" }
        },
        {
          title: "单号",
          align: "center",
          dataIndex: "consumptionNo"
        },
        {
          title: "部门",
          align: "center",
          dataIndex: "deptName"
        },
        {
          title: "款项类型",
          align: "center",
          dataIndex: "paymentType",
          scopedSlots: { customRender: "paymentType" }
        },
        {
          title: "收款单位",
          align: "center",
          dataIndex: "receivingUnit"
        },
        {
          title: "申请人",
          align: "center",
          dataIndex: "applyUserName"
        },
        {
          title: "申请金额",
          align: "center",
          dataIndex: "applyAmount"
        },
        {
          title: "支付人",
          align: "center",
          dataIndex: "payUserName"
        },
        {
          title: "支付日期",
          align: "center",
          dataIndex: "payDate"
        },
        {
          title: "创建日期",
          align: "center",
          dataIndex: "createTime"
        }
      ],
      operator: operator
    }
  },
  created() {
  },
  methods: {
    onLoad() {
      this.$refs.table.refresh()
    },
    processImg(task) {
      this.processInstanceId = task.processInstanceId
      this.processImageVisible = true
    },
    /**
     * 查询事件
     * @param searchParams
     */
    searchTable(searchParams) {
      this.queryParam = Object.assign(this.queryParam, searchParams)
      this.$refs.table.refresh(true, searchParams)
    }
  }
}
</script>
